<?php
namespace Mob \ Model;

use Think \ Model;
use Think \ Hook;
/**请求模型
 * Class InfoModel
 */

require_once ('./Application/Mob/Common/function.php');

class AbilityModel extends Model {



   public function creatorAbility($userId,$enterpriseId,$abilityValue,$industry,$schooId)
   {
   $res = $this->get_IsAbility($userId,$enterpriseId,$abilityValue,$industry,$schooId);
   if($res)
   {
   return true;
   }else
   {
   	$data= array('userId'=>$userId,'schooId'=>$schooId,'enterpriseId'=>$enterpriseId,'abilityValue'=>$abilityValue,'industry'=>$industry,'creationTime'=>time());
   	$this->add($data);

   }
   }

   public function get_IsAbility($userId,$enterpriseId,$abilityValue,$industry,$schooId)
   {
   	 $where = array('userId'=>$userId,'schooId'=>$schooId,'enterpriseId'=>$enterpriseId,'abilityValue'=>$abilityValue,'industry'=>$industry);
   	return   $this->where($where)->find();


   }
   public function get_PersonAbility($userId,$schooId)
   {
   $where = array('userId'=>$userId,'schooId'=>$schooId);
   return $this->where($where)->field('industry,enterpriseId,max(abilityValue) as abilityValue')->group('industry,enterpriseId')->select();


   }










}